// JavaScript Document



//global click listener

//added by leevare



var action = (function() {

    'use strict'



    //namespace

    var action = {}



    var SELECTOR = "[data-action]"



    var _actionList = {}



    function _getActionName($elem) {

        var result = $elem.data("action") || $elem.attr("data-action") || ''

        if(!result) {

            var href = $.trim($elem.attr('href'))

            if(href && href.indexOf('#') === 0) result = href

        }

        return _formatActionName(result)

    }



    function _formatActionName(s) {

        return s ? $.trim(String(s).replace(/^[#!\s]+/,"")) : ''

    }



    function _init() {

        var $wrapper = $(document.body || document.documentElement)

        $wrapper.on("click",SELECTOR,function(e){

            e.preventDefault()

            var $elem = $(this)

            var actionName = _getActionName($elem)

            _handle(actionName,this)

        })

    }



    function _handle(actionName,context) {

        if(!actionName) {

            console.error("[Action] Action name is not exist")

            return

        }

        var fn = _actionList[actionName]

        if(fn && $.isFunction(fn)) {

            return fn.call(context || window,fn.arguments || null)

        }else {

            console.error('[Action] Not found action `%s`.',actionName)

        }

    }



    function add(actionSet) {

        if(!$.isPlainObject(actionSet)) {

            console.error("[Action] Param must be a plain object")

            return

        }



        $.each(actionSet,function(k,v) {

            var actionName = _formatActionName(k)

            if(!actionName) {

                console.error('[Action] The action name `%s` is invalid',actionName)

                return

            }

            if(!$.isFunction(v)) {

                console.error('[Action] The function for action `%s` is invalid',actionName)

                return

            }

            if(_actionList[actionName]) {

                console.warn('[Action] The existing action `%s` has been overwriten',actionName)

            }

            _actionList[actionName] = v

        })

    }



    function trigger(actionName,context) {

        return _handle(_formatActionName(actionName),context)

    }



    _init()



    //export

    action.add = add

    action.trigger = trigger

    return action

}())





$(function(){

    var $fb = $('.fixBar'),

        $fb_exp = $('.fixbar-expand');

	var jFuncSet = {

	    elemScroll : function() {

	        var target = $(this).data('target')

	        var top = $(target).offset().top

	        $("body,html").animate({

	            scrollTop: top

	        },300)

	    },

	    lanToogle: function () {

	      var $lan = $($(this).data("target")),

	              slideTimer = null

	      !$lan.is(":animated") && $lan.slideToggle(300).on("mouseleave", function () {

	        $(this).slideUp(300)

	      }).on("mouseover", function () {

	        clearTimeout(slideTimer)

	      })

	      $(this).on("mouseleave", function () {

	        slideTimer = setTimeout(function () {

	          $lan.slideUp()

	        }, 1500)

	      })

	    },

	    videoLayer: function() {

	        var src = $(this).data('src') || $(this).attr('data-src');

	        layer.open({

	          type: 1,

	          shade: 0.8,

	          title: 'Quick installation',          

	          area: ['650px', '432px'],

	          shadeClose: true,

	          scrollbar: false,

	          content: '<video controls="controls" width="630" height="360"><source src="'+src+'" type="video/mp4"></source></video>'

	        });

	    },

	    freeChat: function() {

	    	if($('.lxb-hide-btn').data('lxb')){

	    	    //$('#LXB_CONTAINER').show();

	            $('#LXB_CONTAINER').css("cssText","top:200px !important;right:38px !important;height: 154px; width: 99px; border: 0px none rgb(0, 0, 0); background-image: url(\"https://lxb.baidu.com/image/module/271796_195646_20160922103705.png?t=1474511823835\"); background-color: rgb(255, 255, 255); position: fixed; display: block !important;");

	    	}

	    },

        fbexpand: function() {

            $fb_exp.animate({

                right: -100

            },300, function() {

                $fb.animate({

                    right: 0

                }, 300, function(){$fb_exp.hide()});

            });

        },

        fbclose: function() {

            $fb.animate({

                right: -40

            },300, function() {

                $fb_exp.show().animate({

                    right: -40

                });

            });

        }

	}



	action.add(jFuncSet)

})



// Header JavaScript

$(".nav_top .navbar-toggle").click(function(){

    $(".nav_top .navbar-text").toggleClass("hidden-xs-di");

})

$(".subnav .navbar-toggle").click(function(){

    $(".subnav ul.nav").toggleClass('j_hide');

    //$(".subnav").toggleClass("subnav_pb");

})



/*$(".languages").click(function(){

    $('.lan').css("display","block");

    $('.languagein').slideToggle(500).siblings(".languagein").slideUp(500);

});

$(".languagein").mouseleave(function(){

    $('.lan').css("display","block");

    $('.languagein').slideToggle(500).siblings(".languagein").slideUp(500);

});



$(".languages").on("click",function(){

	$(".languagein").slideToggle(300).on("mouseout",function(){

		$(".languagein").slideUp(300)

	})

})*/

$(".navbar-left .yewu").click(function(){

    $(".navbar-left .yewu ol").stop(true,true).slideDown(300);

});

$(".navbar-left .yewu").mouseleave(function(){

    $(".navbar-left .yewu ol").stop(true,true).slideUp(300);

});



// Pro_list_wrap JavaScript sorata modified 20160731*/

$(".navbar-inverse li").mouseenter(function(){

	if($(this)[0].className.indexOf('pro_btn')>-1){

	  $(".navbar-inverse .pro_btn").addClass("current");

	  $(".pro_list_wrap").removeClass("hide");

	}else{

		if(!$(".pro_list_wrap").hasClass("hide")){

		$(".pro_list_wrap").addClass("hide");

		$(".navbar-inverse .pro_btn").removeClass("current");

		}

	}

});

/*sorata add 20160728*/

$(".pro_list_wrap").mouseleave(function(){

	if(!$(".pro_list_wrap").hasClass("hide")){

    	$(".pro_list_wrap").addClass("hide");

    	$(".navbar-inverse .pro_btn").removeClass("current");

	}

});



$(document).click(function(){

  if(!$(".pro_list_wrap").hasClass("hide")){

    $(".pro_list_wrap").addClass("hide");

    $(".navbar-inverse .pro_btn").removeClass("current");

  }

});



// Inquiry JavaScript

$(".inquiry").hover(function(){

    $(".inquiry .inquiryCon").show();

  },function(){

    $(".inquiry .inquiryCon").hide();

});

// Search JavaScript

$(".search_box a").on("click", function(e){

    $(".search-expand").show();



    $(document).one("click", function(){

        $(".search-expand").hide();

    });

    e.stopPropagation();

});

$(".search-expand").on("click", function(e){

    e.stopPropagation();

});



// Nav_hovers JavaScript

$(".nav_hovers").mouseenter(function(){

    $(this).find("ol").stop(true,true).slideDown(500);

});

$(".nav_hovers").mouseleave(function(){

    $(this).find("ol").stop(true,true).slideUp(500);

});



// Related-link JavaScript

$(".related-link a").on("click", function(e){

    $(".related-link ul").toggle(200);



    $(document).one("click", function(){

        $(".related-link ul").hide(200);

    });

    e.stopPropagation();

});

$(".related-link ul").on("click", function(e){

    e.stopPropagation();

});



// Contact Us weixin

// $(".show_code").hover( function(event){

//     $(this).children("img").show();    

// }, function(event){

//     $(this).children("img").hide();

// } );



// guanzhu JavaScript

$(".j_hoverTitle").hover(function(){

var a = $(this),

  d = a.data("timerID"),

  e = a.data("isHide");

  clearTimeout(d),

  d = setTimeout(function() { (void 0 === e || e) && ($(".j_hoverCont").stop().css({

		  marginTop: 12,

		  opacity: 0,

		  display: "block"

	  }).animate({

		  marginTop: 0,

		  opacity: 1

	  },

	  function() {

		  a.data("isHide", !1)

	  }))

  },

  300),

  a.data("timerID", d)

},function(){

	var a = $(this),

		d = a.data("timerID");

	clearTimeout(d),

	d = setTimeout(function() {

		$(".j_hoverCont").stop().animate({

			marginTop: 12,

			opacity: 0

		},

		function() {

			$(".j_hoverCont").hide(),

			a.data("isHide", !0)

		})

	},

	300),

	a.data("timerID", d)

});

/*Sorata modified 20160726*/

sUrl = window.location.href.replace("https://"+window.location.host,"");

var findli=0;

actmenu(sUrl);

for(var i=0;i<5;i++){

	if(findli==1){break;}

	newUrl=sUrl.substring(0,sUrl.lastIndexOf("/")+1);

	if(newUrl==sUrl){

		sUrl=sUrl.substring(0,sUrl.lastIndexOf("/"));

	}else{

		sUrl=newUrl;

	}

	actmenu(sUrl);

}

/*鐗规畩澶勭悊濯掍綋涓績鐨勫鑸垽瀹�*/

function checkurl(sUrl){

	switch (sUrl){

		case "/exhibition/":

		case "/news/":

		case "/industrynews/":

		case "/topic/":

		case "/journal/":

		sUrl = "/media/";

		break;

	}

	return sUrl;

}

/*鏍规嵁鍦板潃婵€娲诲綋鍓嶅鑸�*/

function actmenu(sUrl){

	sUrl=checkurl(sUrl);

	$(".topMenu").children('li').each(function(){

		if($(this).children('a').attr('href')==sUrl){

			findli=1;

			$(this).addClass("active");

		}

	});

}







// New livechat Code!
//该死的在线弹出框
//document.writeln("<script language=\'javascript\' src=\'http://pkt.zoosnet.net/JS/LsJS.aspx?siteid=PKT21646611&float=1&lng=en\'></script>");


// for PPC - 鏍囩浼犻€掍唬鐮�

d=document.domain;c=location.search;tags = document.getElementsByTagName("a");for(var i=0;i<tags.length;i++){if(tags[i].href.indexOf('?')==-1 && tags[i].href.indexOf(d)>-1){tags[i].href=tags[i].href+c;}}

document.writeln("<script type=\"text/javascript\" charset=\"utf-8\" async src=\"https://lxbjs.baidu.com/lxb.js?sid=669695\"></script>");

//娴嬭瘯绂荤嚎瀹濈殑杞寲璺熻釜

function checkth() {

    if($('.lxb-cb-input-btn').length>0){

        $('.lxb-cb-input-btn').click(function(){

            _hmt.push(['_trackEvent', 'LXB', 'click', '鎵撶數璇�']);

        });

        window.clearInterval(checktag);

    }

}

var checktag = window.setInterval(checkth, 200);


//Footer addition

function textacc(){
    _gaq.push(['_trackEvent', '鍟嗗姟閫�', '鎺ュ彈', 'chat']);
    _gaq.push(['_linkByPost', this]);
}
function checkopen(){
    if(window.hasOwnProperty('openZoosUrl') && !openZoosUrl.custom)
    {
        window.clearInterval(checking)
        window.openZoosUrl = function(url,data){
            openZoosUrl.custom = true;
            if (typeof(openZoosUrl_UserDefine) == 'function'){if(openZoosUrl_UserDefine())return;};if (typeof (LR_istate) != 'undefined') {LR_istate=3;}var lr_url1=url;if (typeof (LR_opentimeout) != 'undefined' && typeof (LR_next_invite_seconds) != 'undefined')LR_next_invite_seconds=999999;if(url=='sendnote'){url=LR_sysurl+'LR/Chatwin2.aspx?siteid='+LR_websiteid+'&cid='+LR_cid+'&sid='+LR_sid+'&lng='+LR_lng+'&p='+escape(location.href)+lr_refer5238();}else{url=((LR_userurl0 && typeof (LR_userurl) != 'undefined')?LR_userurl:(LR_sysurl+'LR/Chatpre.aspx'))+'?id='+LR_websiteid+'&cid='+LR_cid+'&lng='+LR_lng+'&sid='+LR_sid+'&p='+escape(location.href)+lr_refer5238();}if(typeof(LR_UserSSL) != 'undefined' && LR_UserSSL && url.charAt(4)==':')url=url.substring(0,4)+'s'+url.substring(4,url.length);if(!data){if(typeof(LR_explain)!='undefined' && LR_explain!=''){url+='&e='+escape(escape(LR_explain));}else if(typeof(LiveAutoInvite1)!='undefined'){url+='&e='+escape(escape(LiveAutoInvite1));}}if(typeof(LR_ucd)!='undefined'){url+='&ucd='+escape(LR_ucd);}if(data)url+=data;url+='&d='+new Date().getTime();if(lr_url1=='fchatwin'){LR_ClientEnd=0;window.location=url+'&f=1';return;}var oWindow;try{if (LR_isMobile){if(LR_checkagent('sogoumse')){window.location=url;}else{oWindow=window.open(url);}}else if (LR_checkagent('opera|safari|se 2.x')){oWindow=window.open(url);}else{oWindow=window.open(url,'LRWIN_'+LR_websiteid, 'toolbar=no,width=630,height=435,resizable=yes,location=no,scrollbars=no,left='+((screen.width  - 630) / 4)+',top='+((screen.height - 435) / 4));}if(oWindow==null){LR_ClientEnd=0;window.location=url;return;}oWindow.focus();}catch(e){if(oWindow==null){LR_ClientEnd=0;window.location=url;}}
            textacc();
        } 
    }
}
var checking = window.setInterval(checkopen,200);



$(function(){

    $('.fixBar').animate({

        right: 0

    }, 300);

    //sidebar

    $wrapper = $(document.body || document.documentElement);

    $('.icon-toggle').on('click',function(e) {

        e.preventDefault();

        e.stopPropagation();

        $('.sidebar').stop(true).addClass('s-translate');

        $wrapper.css({

            'height': $(window).height(),

            'overflow': 'hidden'

        });

    })

    $('.left-arrow-icon').on('click', function(e) {

        e.preventDefault();

        e.stopPropagation();

        $('.sidebar').stop(true).removeClass('s-translate');

        $wrapper.css({

            'height': 'auto',

            'overflow': 'auto'

        });

    })

    $('.sidebar').on('click', function(e) {

        e.stopPropagation();

    });

    $('.sidebar-menu > li').each(function(){

        var _t = $(this);

        _t.find('a').first().on('click',function(e){

            e.stopPropagation();

            _t.find('.sidebar-sub-menu').stop(true).slideToggle().parent().siblings('li').find('.sidebar-sub-menu').stop(true).slideUp();

        })

    });

    $wrapper.on('click', function() {

        $('.sidebar').stop(true).removeClass('s-translate');

        $(this).css({

            'height': 'auto',

            'overflow': 'auto'

        });

    });

});



var hoverTimer;

$('.fixBar li').hover(function() {

    var that = $(this);

    hoverTimer = setTimeout(function() {

        that.children(".over-mask").show().css({

            opacity: 0

        }).stop().animate({

            right: parseInt(that.css('width')),

            opacity: 1,

        });

    }, 200);

}, function() {

    var that = $(this);

    clearTimeout(hoverTimer);

    setTimeout(function() {

        that.children(".over-mask").stop().animate({

            right: parseInt(that.css('width')) + 20,

            opacity: 0

        }, 'normal', 'linear', function() {

            that.children(".over-mask").hide();

        });

    }, 200);

})

var m;

m = setInterval(function() {

    if($('.lxb-hide-btn').length > 0) {

        clearInterval(m);

        $('.lxb-hide-btn').data('lxb', 'lxb').unbind();

        $('#LXB_CONTAINER').css("cssText","top:200px !important;right:9999px !important;height: 154px; width: 99px; border: 0px none rgb(0, 0, 0); background-image: url(\"https://lxb.baidu.com/image/module/271796_195646_20160922103705.png?t=1474511823835\"); background-color: rgb(255, 255, 255); position: fixed; display: block !important;");

        $('.lxb-hide-btn').on('click',function(e) {

            e.preventDefault();

            e.stopPropagation();

            $('#LXB_CLOSE_BTN').hide();

            $('#LXB_CONTAINER').hide();

        })

    }

}, 200);